<%@ LANGUAGE="VBSCRIPT" %>
<%'  ------------------------------------------------------------
  '  mz_propcontent.asp 
  '  ------------------------------------------------------------
  '  VCS INFO:
  '  
  '  $Revision:   1.35  $
  '  $Date:   08 Oct 1998 16:04:44  $
  '  $Author:   rurman  $
  '  $Workfile:   mz_propcontent.asp  $
  '  ------------------------------------------------------------
  '  All Rights Reserved.  Copyright (c) 1988-1998 FileNET Corp.
  '  ------------------------------------------------------------
  '%>
<!-- #include file="islogon.asp" -->
<%
DebugFlag = 0

RequestMethod = Request.ServerVariables("REQUEST_METHOD")
if RequestMethod = "POST" then
    ObjType = CInt(Request.Form("Type"))
    Ident = Request.Form("Ident")
else
    ObjType = CInt(Request.QueryString("Type"))
    Ident = Request.QueryString("Ident")
    Update = Request.QueryString("Update")
    Status = Request.QueryString("Status")
end if 

ShowHintsFlag = Session("ShowHints")

'Panagon IDM Web application uses the Session variable LibraryLogonID to keep track of
'whether the user has logged on.
'Please see logoncall.asp to see how the Session variable LibraryLogonID is set.
LibraryLogonID = Session("LibraryLogonID")
set LibraryObj = Server.CreateObject("IDMObjects.Library")
LibraryObj.LogonID = LibraryLogonID

On Error Resume Next
set FObj = LibraryObj.GetObject(ObjType, Ident)
if Len(Err.Description) then
    Response.Expires = 0
    Response.Status = "404 Not Found"
    Response.ContentType = "text/plain"
    Response.Write "Document not found: "
    Response.Write Err.Description
    Response.End
end if

%>

<!-- #include file="jscriptfix.asp" -->
<!-- #include file="convtohints.asp" -->
<!-- #include file="checkutil.asp" -->

<% if DebugFlag then %>
Form<br>
<% For Each x In Request.Form %>
<%if not (Request.Form(x) = "") then %>
<!-- <INPUT TYPE=hidden name="<%= x %>" value="<%= Request.Form(x) %>"> -->
name="<%= x %>" value="<%= Request.Form(x) %>"<br>
<% end if %>
<% Next 
end if %>

<SCRIPT LANGUAGE="JavaScript">
<!--
// call the ASP to enter Multi Value Property 
function MayPickMVProperty(docid, index, ObjType)
{

  // location.href = "mz_MVPMayPick.asp?Type="+ObjType+"&Ident=" + docid + "&PropIndex=" + index;
    document.property.PropIndex.value=index;
    document.property.UpdateFlag.value = "0";
    document.property.action = "mz_MVPMayPick.asp";
    document.property.submit();
}
//-->
</SCRIPT>

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>

<head>
<meta http-equiv="Content-Type"
content="text/html">
<meta name="GENERATOR" content="Microsoft FrontPage 2.0">
<title>Property Modify</title>
</head>

<body bgcolor="#FFFFFF">

<table border="0" cellpadding="4" cellspacing="0">
    <tr>
        <td nowrap><% if ObjType = Application("idmObjTypeDocument") then %><img src="images/ldoc.gif" width="34" height="39"><% else %><img
        src="images/lfolder.gif" width="38" height="39"><% end if %><font
        size="3"><strong><%= Ident %> ("<%=Server.HTMLEncode(FObj.Label)%>") :  </strong></font>
        <font size="3"><strong> Modify Document Properties </strong></font>
        <% 
        if Update = "1" then
            if Status = "1" then %>
                <font color="#0000FF" size="4"><strong><em>
                ( Properties updated successfully. )
            <% elseif Status = "-1" then %>
                <font color="#AA0000" size="4"><strong><em>
                ( Properties update failed ! )
        <%  end if %>
            </em></strong></font>
        <% end if %>
        </td>
    </tr>
    
</table>

<%
set Props = FObj.Properties
if Status <> "" and Status <> "1" then
    SubmittedValues = Session("SubmittedValues")
    ValidationStatus = Session("ValidationStatus")
end if
IsVirtual = false
if ObjType = Application("idmObjTypeFolder") then

    if FObj.GetState(5) then ' 5=idmFolderIsReplica
            IsVirtual = true
    end if

end if
%>
<!-- action="mz_propupdate.asp" -->
<form name="property"  method="POST">

<table border="0" cellpadding="0" cellspacing="1">
    <tr>
    <td>&nbsp;</td>
    <td colspan=4>
    <input type="checkbox" name="ShowHints" language="JavaScript" onclick="ShowPropertyHints()"
        <% 
        ' the ShowHints displays the Data Type of each property
        if ShowHintsFlag then %>checked<% end if %>><font size=2>Show Property Hints</font>
    </td>
    
    <!-- <td align=right nowrap> 
        <% if not IsVirtual then %>
        <input type="radio" name="Validate" language="JavaScript" OnClick="ValidateProps()"><font size=2>Validate Now</font>
        <% end if %> -->
    </td>
    </tr>
</table>
<br>
<% IEBrowser = InStr(Request.ServerVariables("HTTP_USER_AGENT"), "MSIE")
if IEBrowser then %>
<table frame="box" rules="groups" border="1" cellpadding="0" cellspacing="1">
<% else %>
<table frame="box" rules="groups" border="0" cellpadding="0" cellspacing="1">
<% end if %>
<COLGROUP>
    <COL SPAN="3" ALIGN="left">
<COLGROUP>
    <COL SPAN="3" ALIGN="left">
<THEAD>
    <tr>
        <td align="center" width="30" bgcolor="#EECCFF">&nbsp;</td>
        
        <td align="center" bgcolor="#EECCFF">&nbsp;</td>
        <td align="center" width="200" bgcolor="#EECCFF"><font
        size="3"><strong>Property</strong></font></td>
        <td align="center" width="200" bgcolor="#EECCFF"><font
        size="3"><strong>Value</strong></font></td>
        <td align="center" width="12" bgcolor="#EECCFF">&nbsp;</td>
        <td align="center" width="12" bgcolor="#EECCFF">&nbsp;</td>
        
    </tr>
<TBODY>
    <% 'enumerate through the document Properties, to display each prop name and value

    for i=1 to Props.Count
        set Prop = Props(i)
        set PropDesc = Prop.PropertyDescription
        propName = Prop.Name
        delName="DELETE_" + UCase(Prop.Name) ' used for MultiValue Props
        addName="ADD_" + UCase(Prop.Name)    ' used for MultiValue Props
        if PropDesc.Name <> "idmDocCheckouts" then
        %>
    <tr>
    <td valign=top align=right></td>
    
    <td valign=top align=left>
    <% 
    
    IsReadOnly = PropDesc.GetState(Application("idmPropReadOnly"))
    if PropDesc.GetState(Application("idmPropRequired")) then ' this is a required property
    %>
    <font color="#FF0000" size="5"><strong>*</strong></font>
    <% 
    end if
    if PropDesc.GetState(Application("idmPropVersion")) then ' this is a Version property
    %>
    <font color="#FF0000" size="3"><strong>v</strong></font>
    <%  end if %>
    </td>

    <td valign=top><em><%= Server.HTMLEncode(Prop.Label) %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</em></td>
    <td valign=top>
    <% value = ""
       if Status <> "" and Status <> "1" then
            value = SubmittedValues(i)
       end if
    %>
<!-- #include file="mz_ValueString.asp" --> 

       <%
       ' depending on property type, there is a different control to enter the property value 
       if IsReadOnly then 
         v = Prop.FormatValue 
        
         if v = "Null" then %>
        <%= value %>
        <% else %>
        <%= v %>
        <% end if
        
       ' case of MultiValue property ========================
       elseif PropDesc.GetState(Application("idmPropMultiValue")) then 
            set MVProp = Prop.Value ' object is a MultipleValues
            
            if ( PropDesc.GetState(Application("idmPropMustPick"))) then
            ' is there a selection list for this Multi Value Prop ?
             IsChoicePaging = PropDesc.GetState(Application("idmChoicePaging"))
             if IsChoicePaging  then 
                set Choices = PropDesc.Choices
                set oPaging = Choices.Paging
                iPage=1
                'PageSize=50 ' update this value along with "if Choices.Count=50 then" below
                'oPaging.Size=PageSize ' number of choices to retrieve, default is 50
                call oPaging.NextPage(NULL,1) ' idmForward is default
                Count=Choices.Count

            %>
                <%= value %> <br>
                <select multiple name="<%= addName %>" size="3">
        
            <%
                ' if property not required, allow also empty string as choice =======
                if (not PropDesc.GetState(Application("idmPropRequired"))) then 
                %>
                <option value=""<% if ""=value then %> selected <%end if%> > </option>
                <%
                end if
                ' enumerate through the Choices, to create the dropdown selection list =====
                do until Count=0
                    for k=iPage to Choices.Count
                        ChoiceStrVal = PropDesc.FormatValue(Choices.Item(k).Value)
            %>
                <option value="<%= ChoiceStrVal %>"
                    <% if Request.Form(addName).Count > 0 then ' ===== check against FORMs param
                        for m=1 to Request.Form(addName).Count
                                ThisStrVal = Request.Form(addName)(m)
                                if ChoiceStrVal=ThisStrVal then %> 
                                    selected     <% exit for 
                                end if
                             
                        next
                       else         ' select the current property values 
                        for m=1 to MVProp.Count 
                            ThisStrVal = PropDesc.FormatValue(MVProp.Item(m))
                            if ChoiceStrVal=ThisStrVal then %> 
                                selected     <% exit for
                            end if
                        next
                       end if
                    %>
                 > <%= ChoiceStrVal %> </option>
                        
            <%
                    next
                ' need to check if MORE choices
                  if Choices.Count=50 then  
                  ' check against preset PageSize, to see if there are more results to be displayed
                    iPage=2 ' to skip the first element in the results list (it has the search  key)
                    call oPaging.NextPage(Choices.Item(k - 1).Value, 1)
                    Count=Choices.Count
                  else Count=0
                  end if
                loop
            %>

                </select>
            <% end if
            else ' MayPick values entered in MultiValue Property page ================
                
            %>
                <%= value %>
                <% for p=1 to Request.Form(delName).Count %>
                <INPUT TYPE=hidden name="<%=delName%>" value="<%= Request.Form(delName)(p) %>">
                <% next %>
                <% for p=1 to Request.Form(addName).Count %>    
                <INPUT TYPE=hidden name="<%=addName%>" value="<%= Request.Form(addName)(p) %>"> 
                <% next %>
            
            <% end if %>
                
        <%
        ' case of single value property with the type: must set by ID (by index, not by value) ====================
        elseif PropDesc.GetState(Application("idmPropMustSetByID")) then
            ' check if there is a selection list
            IsChoicePaging = PropDesc.GetState(Application("idmChoicePaging"))
            if IsChoicePaging   then 
                set Choices = PropDesc.Choices 
                set oPaging = Choices.Paging
                call oPaging.NextPage(NULL,1) ' idmForward is default
                Count=Choices.Count
                if Request.Form(propName).Count > 0 then ' ===== check against FORMs param
                    thisVal=PropDesc.FormatValue(CLng(Request.Form(propName)))
                else
                    thisVal=Prop.FormatValue
                end if
        %>
            <select name="<%= Prop.Name %>" size="1">
        <%
                for k=1 to Choices.Count
                    ChStrVal = PropDesc.FormatValue(Choices.Item(k).Value)

        %>
            <option value="<%= Choices.Item(k).Value %>" <% if thisVal=ChStrVal then %> 
                selected <% end if%> > <%= ChStrVal %> </option>
        <%
                next
        %>
            </select>
        <%
            end if
        ' case of single value property w/ selection list
        ' check idmPropHasCVL ===============================
        elseif PropDesc.GetState(Application("idmPropHasCVL")) then ' idmPropMustPick
            IsChoicePaging = PropDesc.GetState(Application("idmChoicePaging"))
            if IsChoicePaging   then 
                set Choices = PropDesc.Choices
                set oPaging = Choices.Paging
                iPage=1
                'PageSize=50 ' update this value along with "if Choices.Count=50 then" below
                'oPaging.Size=PageSize ' number of choices to retrieve, default is 50
                call oPaging.NextPage(NULL,1) ' idmForward is the default
                Count=Choices.Count
                if Request.Form(propName).Count > 0 then ' ===== check against FORMs param
                    thisVal=Request.Form(propName) ' if date, it is already formatted
                else
                    thisVal=value
                end if
        %>
            <select name="<%= Prop.Name %>" size="1">
                <% 
                if (not PropDesc.GetState(Application("idmPropRequired"))) then %>
            <option value=""<% if ""=thisVal then %> selected <%end if%> > </option>
                <% end if %>
        <%
                do until Count=0
                    for k=iPage to Choices.Count
                        StrVal = PropDesc.FormatValue(Choices.Item(k).Value)
        %>
            <option value="<%= StrVal %>" <% if StrVal=thisVal then %> 
                selected <% end if%> > <%= StrVal %> </option>
        <%
                    next
                ' need to check if there are MORE choices to be displayed
                  if Choices.Count=50 then  ' check against PageSize
                    iPage=2 ' to skip the search  key
                    call oPaging.NextPage(Choices.Item(k - 1).Value, 1)
                    Count=Choices.Count
                  else Count=0
                  end if
                loop
        %>
            </select>
        <%
            end if
         %>
        
            
        <%
       elseif ObjType = Application("idmObjTypeFolder") and IsVirtual then %>
        <%= value %>

    <% elseif Prop.TypeID = Application("idmTypeBoolean") then %>
        <select name="<%= Prop.Name %>" size="1">
            <option value="1" <% if value = 1 then %>selected<% end if %>>True</option>
            <option value="0" <% if value = 0 then %>selected<% end if %>>False</option>
        </select>

    <% 
    ' case of single value string entered as input TEXT ====================
    else 
        if ObjType = Application("idmObjTypeDocument") then
            FieldSize = PropDesc.Size
        else
            FieldSize = -1
        end if
    %>
        <input type="text" size="50" name="<%= Prop.Name %>"
            <% if FieldSize > 0 then %>
            maxlength=<%= FieldSize %>
            <% end if %>
            <%
            ' check if the value comes from the request form or the already set value
            if Request.Form(propName).Count > 0 then ' ===== check against FORMs param
            %>
                value="<%= Request.Form(propName) %>"
            <% else %>
                value="<%= value %>"
            <% end if %>
            
            <% if PropDesc.TypeID = Application("idmTypeDate") then %>
            onBlur="CheckDate(this, '<%=value%>')"
            <% elseif PropDesc.TypeID = Application("idmTypeLong") or PropDesc.TypeID = Application("idmTypeShort") _ 
             or PropDesc.TypeID = Application("idmTypeSingle") _
             or PropDesc.TypeID = Application("idmTypeUnsignedShort") or PropDesc.TypeID = Application("idmTypeUnsignedLong")   then %>
            onBlur="CheckInteger(this, '<%=value%>')"
            <% end if %>

            <% if PropDesc.GetState(Application("idmPropRequired")) then %>
            onChange="CheckSelected(this)"
            <% end if %>
            >
    <% end if %>
    </td>

    <td valign=top nowrap>
    <% if (not IsReadOnly) then %>
        <% 
        if Prop.TypeID=Application("idmTypeObject") then
            if (not PropDesc.GetState(Application("idmPropMustPick"))) then 
         %>
        <a target="PropContent" HREF="javascript:MayPickMVProperty('<%=Ident%>','<%=i%>',<%=ObjType%>)">
    <img alt="Modify MultiValued Property" src="images/smodify.gif" align=bottom border=0 width=24 height=22></a>
            <% else %>
    <!--    <a target="PropContent" HREF="javascript:MustPickMVProperty('<%=Ident%>', '<%=i%>', <%=ObjType%>)">
    <img alt="Modify MultiValued Property" src="images/smodify.gif" align=bottom border=0 width=24 height=22></a> -->
            <% end if %>
        <% elseif ShowHintsFlag then %>
            <font size="2">(<%= ConvertToHints(ObjType, PropDesc) %>)</font>
        <% end if %>
    <% end if %>
    </td>
    <td valign=top nowrap>
    <% if Status = "-1" then
            if ValidationStatus(i) = "-1" then %>
                <font color="#AA0000" size="2"><strong><=== <em>Invalid</em>, was <%= Prop.Value %></strong></font>
    <%      end if
       end if %>
    </td>

    </tr>
    
    <% 
        end if
    next %>
</table>
<%
if IEBrowser then %>
<br>
<% else %>
<hr>
<% end if %>
<table border="0" cellpadding="0" cellspacing="1">
    <tr>
    <td width="30" valign=bottom align=right></td>
    <td>
    <% if not IsVirtual then %>
    <a href="javascript:Update()"><img alt="Update Properties" src="images/update.gif" align=bottom border=0 width=41 height=41></a><em><strong>Update</strong></em>
    <a target="_top" href="security.asp?Ident=<%=Ident%>&Type=<%=ObjType%>&Modify=1"><img alt="Modify Security" src="images/lockbut.gif" align=bottom border=0 width=47 height=43></a><em><strong>Modify Security</strong></em>
    <% end if %>
    </td>
    </tr>
</table>
<input type="hidden" name="Type" value="<%= ObjType %>">
<input type="hidden" name="Ident" value="<%= Ident %>">
<input type="hidden" name="PropIndex" value="">
<input type="hidden" name="UpdateFlag" value="1">
<input type="hidden" name="CheckIn" value="No">
</form>


<SCRIPT LANGUAGE="JavaScript">
<!--
function ShowPropertyHints()
{
    document.property.action = "mz_propupdate.asp";
    document.property.UpdateFlag.value = "0";
    document.property.submit();
}

function ValidateProps()
{
    document.property.action = "mz_propupdate.asp";
    document.property.UpdateFlag.value = "0";
    document.property.submit();
}

function Update()
{
    document.property.action = "mz_propupdate.asp";
    document.property.UpdateFlag.value = "1";
    document.property.submit();
}

//-->
</SCRIPT>

<!-- #include file="mz_checksel.asp" -->

&nbsp;<br>
</body>
</html>
